{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="{:url('admin/service/index')}">劳务信息</a>
            </li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <h3 class="header smaller lighter blue">劳务队信息</h3>
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <!--<a href="{:url('admin/service/addservice')}" class="btn btn-default">添加劳务</a>
                            <br><br>-->
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>项目名称</th>
                                        <th class="hidden-480">劳务队名称</th>

                                        <th>
                                            劳务队人数
                                        </th>
                                        <th class="hidden-480">特种人员数量</th>
                                        <th class="hidden-480">机具备案</th>
                                        <th class="hidden-480">劳务分包内容</th>
                                        <th class="hidden-480">状态</th>
                                        <th class="hidden-480">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="service" id="v"}
                                    <tr>
                                        <td>{$v['id']}</td>
                                        <td>{$v['project_name']}</td>
                                        <td>{$v['service_team_name']}</td>
                                        <td>{$v['user_num']}</td>
                                        <td>{$v['special_personnel_num']}</td>
                                        <td>{$v['machines_record']}</td>
                                        <td>{$v['labor_subcontract']}</td>
                                        <td>
                                            <?php if ($v['status'] == 1): ?>
                                                通过
                                            <?php else: ?>
                                                审核中 <u><a href="{:url('admin/service/dostatus', ['id' => $v['id']])}" class="btn btn-success btn-xs">通过</a></u>
                                            <?php endif ?>
                                        </td>

                                        <td>
                                            <a href="{:url('admin/service/edit', ['id' => $v['id']])}" class="btn btn-primary btn-xs">修改</a> | 
                                            <button data-id="{$v['id']}" class="btn btn-danger del-btn btn-xs">删除</button>
                                        </td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                        </div>
                        {$service->render()}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="myjs"}
{js href="/static/admin/assets/js/toastr.min.js"}
<script>
    $(function(){
        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            console.log('我要删除: ' + ac_id + '的劳务信息');
            if (confirm('你确定要 [ 删 除 ] 吗?')) {
                var obj = $(this).parents('tr');
                // console.log(obj);
                delAjax(ac_id, obj);
            }
        });

    });

    // 执行ajax删除
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/Service/' + id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }

</script>
{/block}







